home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
kg_df105.zip
/
DF.8
next >
Wrap
Text File
|
1993-03-15
|
14KB
|
348 lines
;========================================================================== DF.8
; Program: Disk Free
; Version: 1.05
; Creator: Kevin O. Grover, INet: grover@cs.unlv.edu
; System: A86 V3.22 by Eric Isaacson
; Cre Date: 14 Dec 1988
; Mod Date: 15 Mar 1993
; Syntax: DF [d:] [?] [/s]
; History:
; ==============================================================================
; Date Vers Description of Modifications/Additions
; ----------- ---- -----------------------------------------------------------
; 14 Dec 1988 1.02 Original Version (as far as I can tell)
; 16 Feb 1991 1.03 Changed name to DF (from DI, because Norton used DI).
; Added comments, changed address in help, used tabs in help.
; Added Public Domain notice in Help message.
; 01 Oct 1991 1.04 Added /s option to enable statistics of the drive, they
; are not displayed by default
; 15 Mar 1993 1.05 Cleaned up text included in executable
; ==============================================================================
;
; Desc: This program displays the amount of avaliable, used, and free disk
; space in bytes. It also indicates the used and free space in terms
; of a percentage of the over all total disk space avaliable.
; In addition, sector and clustor information can be printed as
; an option.
;
; Note: Syntax for function 36h of Int 21H
; AH = 36h
; DL = dirve code (0=defualt, 1=A, 2=B, etc..)
;
; On Exit: if specified drive was vaild:
; AX = Sectors per cluster
; BX = number of available clusters
; CX = bytes per sector
; DX = clusters (allocation untis) per drive
; if the specified drive was invalid:
; AX = FFFFh
;
; ToDo: - Add /s (stats) option. If specified, display sector and cluster
; information. Otherwise, only display percentage and usage info.
;
; Bugs: - The parsing of the command line does not do many error checks
; (it is not very robust, but it is small)
; ==============================================================================
; ---------------------------------------------------------------------- Equates
Width EQU 14 ; Width of the field to print numbers in
Adjust EQU 10000 ; Used to compute and format the percentages
CR EQU 13 ; Carrage return
LF EQU 10 ; Line Feed
TAB EQU 9 ; Tab Character
; ----------------------------------------------------------------- Macro: Write
Write Macro
MOV AH, 9
LEA DX, #1
INT 21h
#EM
; ----------------------------------------------------------------- Macro: Print
Print Macro
MOV Ah, 2
MOV DL, #1
INT 21h
#EM
; ----------------------------------------------------------- Start of MAIN Code
Write Hello ; Print opening messages
MOV DI, 80h ; Check the command line for /? option for help!
MOV CH, 0
MOV CL, Byte Ptr [DI]
JCXZ SkipOptionCheck ; If zero, use the defualt drive
FindNextOption:
INC DI ; Point to the first byte
MOV AL, '/'
REPNE Scasb
JNE SkipOptionCheck
CMP Byte Ptr [DI], '?' ; Check for /? (help) option
JNE SkipHelp
Write Help ; Show help
MOV AX, 4C00h ; Terminate with a zero return code
INT 21h ; Do terminate
SkipHelp:
CMP Byte Ptr [DI], 's' ; check for /s (stats) option
JNE IllegalOption
MOV BYTE PTR ShowStatsFlg, 1 ; Turn Show stats on
JMP FindNextOption ; Look for next Option
IllegalOption:
Write IllOption ; Illegal Option
MOV AX, 4C01h ; Terminate with a return code of 1
INT 21h ; Do Terminate
; Start of Actual Program, i.e. No more option processing
SkipOptionCheck:
MOV Dl, [05Ch] ; Get the drive number from the FCB
MOV AH, 36h ; Function to get the disk info
INT 21h ; Get the info
CMP AX, 0FFFFh ; Test for an error reading the info
JNE NoError ; If error no error, go on
Write ErrorM ; OtherWise, Print and error message, and terminate
MOV AX, 4C01
INT 21h ; Terminate with return code 1
NoError:
MOV SecClus, AX ; Save the returned values.
MOV Free, BX
MOV ByteSec, CX
MOV Total, DX
XOR DX, DX
MUL ByteSec
MUL Total
MOV TotalBy, AX
MOV TotalBy+2, DX
MOV BX, Width
CALL LNum
Write TotalB
MOV AX, Free ; Calculate the percent of free space
MOV BX, Adjust ; Multiply by 10000 to give result in the
MUL BX ; form XXXX where it = XX.XX %
DIV Total ; Divide by the total
MOV Percent, AX ; Store the result
MOV AX, SecClus
XOR DX, DX
MUL ByteSec
MUL Free
MOV FreeBy, AX
MOV FreeBy+2, DX
MOV BX, Width
CALL LNum
Write FS ; Print the message for free space
MOV AX, Percent
CALL Per ; Print the percentage free
MOV AX, TotalBy
SUB AX, FreeBy
MOV DX, TotalBy+2
SBB DX, FreeBy+2
MOV BX, Width
CALL LNum
Write US ; Print the percent of used space
MOV AX, Adjust
SUB Ax, Percent ; Use Percent free to find percent used
CALL Per ; Call the percent output routine
CMP ShowStatsFlg, 0 ; Should we display statistics?
JE SkipStats ; If not, jump to end
Print 10 ; Leave a Blank Line
MOV AX, Total
MOV DX, 0
MOV BX, Width
CALL LNum
Write TCluster ; Print the total number of clusters.
MOV AX, Free
MOV DX, 0
MOV BX, Width
CALL LNum
Write Cluster ; Print the number of free clusters.
MOV AX, SecClus
MOV DX, 0
MOV BX, Width
CALL LNum
Write Sectors ; Print the number of sectors per cluster.
MOV AX, ByteSec
MOV DX, 0
MOV BX, Width
CALL LNum
Write BSector ; Print the number of bytes per sector.
SkipStats:
MOV AX, 4C00h
INT 21h ; Quit the program. (Return code = 0)
; -------------------------------------------------------------------------- Per
; Per takes the number in AX (xxx) and prints it as a percentage (xx.x%)
Per Proc Near
PUSH AX
MOV AH, 2
MOV DL, '('
INT 21h
POP AX
MOV Bl, 100
DIV BL ; Divide by ten to get the decimal part
PUSH AX ; Save the result on the stack
MOV DX, 0
MOV Ah, 0 ; Clear the remainder
MOV BX, 3 ; Field for the left part
CALL Lnum ; Print the quoitent (the percentage)
MOV Dl, '.' ; Print a decimal point
MOV Ah, 2
INT 21h
POP Ax ; Get the result back fr